#include<bits/stdc++.h>

using namespace std;

const int MAXN = 3010;

typedef struct {int v,nxt;}edge;

int a[MAXN],n,cnt,h[MAXN];
bool dp[MAXN];
edge e[MAXN<<1];

void link(int x,int y){e[++cnt] = (edge){y,h[x]};h[x] = cnt;}

void dfs(int x,int p){
	dp[x] = 0;
	for(int i = h[x];i;i = e[i].nxt){
		int y = e[i].v;
		if(y == p) continue;
		dfs(y,x);
		if(dp[y] == 0 && a[y] < a[x]) dp[x] = 1;
	}
}

int main (){
	scanf("%d",&n);
	for(int i = 1;i <= n;i++) scanf("%d",&a[i]);
	for(int i = 1;i < n;i++){
		int x,y;
		scanf("%d %d",&x,&y);
		link(x,y);link(y,x);
	}
	for(int i = 1;i <= n;i++){
		dfs(i,0);
		if(dp[i]) printf("%d ",i);
	}
	return 0;
}
